home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / html / util / genskunk.03 < prev    next >
Text File  |  1998-03-23  |  10KB  |  409 lines

  1. #! /usr/local/bin/perl -w 
  2.  
  3. $0 =~ s,.*/,,;
  4. $version="v1.1";
  5. $program=$0;
  6. $debug=0;
  7. $mailto='mailto:skunkware@sco.com';
  8. $baseref='http://www.sco.com/skunkware';
  9. $homeref='http://www.sco.com/skunkware';
  10. $isweb=0;
  11.  
  12. sub usage {
  13.   warn "@_\n" if @_;
  14.   $! = 0;
  15.   die <<EOF;
  16. Usage: $0 -w | -c file name prev next
  17.   -w        - Generate pages for the Web
  18.   -c        - Generate pages for the CD-ROM
  19.   file      - name of the template (.tmpl) file
  20.   name      - the name of the package
  21.   prev      - the name of the previous link
  22.   next      - the name of the next link
  23.  
  24.   Use the word NONE for the prev and next parameters if the page doesnt
  25.   have a previous or next page in the document chain.
  26.  
  27. EOF
  28. }
  29.  
  30. if (@ARGV<1 || $#ARGV != 4) {
  31.   usage();
  32. }
  33.  
  34. $mode="0";
  35.  
  36. if($ARGV[0] eq "-w" || $ARGV[0] eq "web") {
  37.   $mode="SKUNK_WEB";
  38.   $isweb=1;
  39. }
  40. elsif($ARGV[0] eq "-c" || $ARGV[0] eq "cd") {
  41.   $mode="SKUNK_CD";
  42.   $baseref='..';
  43. }
  44.  
  45. if ($mode eq "0") {
  46.   usage();
  47. }
  48.  
  49. $now=`date '+%A %b %d, %Y at %T %Z'`; chop $now;
  50. $basefile=$ARGV[1];
  51. $shortname=$ARGV[2];
  52. $previous=$ARGV[3];
  53. $next=$ARGV[4];
  54. $realbase=`basename $basefile`; chop $realbase;
  55. #if ($isweb) {
  56. #  if (not -d $shortname) {
  57. #    mkdir($shortname,0755) or die "$program error: Could not create directory $shortname\n";
  58. #  }
  59. #  $output="$shortname/index.html";
  60. #} else {
  61.   $output="${realbase}.html";
  62. #}
  63. $template="${basefile}.tmpl";
  64. $templflt="/lib/cpp -I. -I.. -I../src -D$mode $template |";
  65.  
  66. -f $template or die "$program error: $template not found\n";
  67.  
  68. if ($debug) {
  69.  print "basefile : $basefile\n";
  70.  print "now      : $now\n";
  71.  print "shortname: $shortname\n";
  72.  print "previous : $previous\n";
  73.  print "next     : $next\n";
  74.  print "output   : $output\n";
  75.  print "realbase : $realbase\n";
  76.  print "template : $template\n";
  77. }
  78.  
  79. if ($previous eq "none" or $previous eq "NONE")
  80. {
  81.     $prevref="";
  82. } else {
  83.     if ($isweb) {
  84.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"\/skunkware\/$previous/index.html\">";
  85.     } else {
  86.         $prevref="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$previous.html\">";
  87.     }
  88. }
  89.  
  90. if ($next eq "none" or $next eq "NONE") {
  91.     $nextref="";
  92. } else {
  93.     if ($isweb) {
  94.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"\/skunkware\/$next/index.html\">";
  95.     } else {
  96.         $nextref="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$next.html\">";
  97.     }
  98. }
  99.  
  100. if ($debug) {
  101.  print "nextref=$nextref\n";
  102.  print "prevref=$prevref\n";
  103. }
  104.  
  105. open (TEMPLATE,$templflt) or die "$program error: cannot open $template for reading\n";
  106. open (OUTPUT,">$output") or die "$program error: cannot open $output for output\n";
  107.  
  108. sub skunkheader{
  109.     my($foo) = @_;
  110.     my($title,$plink,$nlink) = split(/;/,$foo);
  111.     my($oplink,$onlink);
  112.     if (not $plink) {
  113.         $oplink = $prevref;
  114.     } else {
  115.         if ($isweb) {
  116.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink/index.html\">";
  117.         } else {
  118.             $oplink="<AREA SHAPE=\"rect\" COORDS=\"112,2,236,26\" HREF=\"$plink.html\">";
  119.         }
  120.     }
  121.     if (not $nlink) {
  122.         $onlink = $nextref;
  123.     } else {
  124.         if ($isweb) {
  125.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink/index.html\">";
  126.         } else {
  127.             $onlink="<AREA SHAPE=\"rect\" COORDS=\"252,1,331,26\" HREF=\"$nlink.html\">";
  128.         }
  129.     }
  130.  
  131.     if ($debug) {
  132.         print "skunkheader: title='$title'\n";
  133.         print "             oplink='$oplink'\n";
  134.         print "             onlink='$onlink'\n";
  135.     }
  136.  
  137.     if (not $title) {
  138.         warn "$program: No TITLE specified in SKUNKHEADER\n";
  139.     }
  140.  
  141.     if (not $isweb) {
  142. #
  143. # This is the header information for the Skunkware CD-ROM
  144. #
  145.         print OUTPUT <<EOF;
  146. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  147. <!-- DO NOT EDIT -->
  148. <!-- Automatically generated from $template by $program $version -->
  149. <!-- DO NOT EDIT -->
  150. <HTML>
  151. <HEAD>
  152.   <TITLE>$title</TITLE>
  153.   <LINK REV="made" HREF="$mailto">
  154. </HEAD>
  155. <BODY BGCOLOR="#ffffff">
  156.  
  157. <MAP NAME="skunknav">
  158.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$homeref/$shortname">
  159.   $oplink
  160.   $onlink
  161.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="$baseref/index.html">
  162. </MAP>
  163.  
  164. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  165.   <TR ALIGN="LEFT" VALIGN="TOP">
  166.     <TD ROWSPAN="2" WIDTH="20%">
  167. <A HREF="http://www.sco.com/skunkware">
  168.       <IMG BORDER=0 SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  169. </A>
  170.     </TD>
  171.     <TD VALIGN="BOTTOM" WIDTH="79%">
  172.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  173.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  174.     </TD>
  175.   </TR>
  176.   <TR>
  177.     <TD VALIGN="TOP">
  178.       <IMG SRC="gif/${shortname}.gif" ALT="$title" HEIGHT="26" ALIGN="BOTTOM">
  179.     </TD>
  180.   </TR>
  181. </TABLE>
  182.  
  183. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  184. EOF
  185.   } else {
  186. #
  187. # This is the header information for the Skunkware On-line pages
  188. #
  189.     print OUTPUT <<EOF;
  190. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  191. <!-- DO NOT EDIT -->
  192. <!-- Automatically generated from $template by $program $version -->
  193. <!-- DO NOT EDIT -->
  194. <HTML>
  195. <HEAD>
  196.   <TITLE>$title</TITLE>
  197.   <LINK REV="made" HREF="$mailto">
  198. </HEAD>
  199. <BODY BGCOLOR="#ffffff">
  200.  
  201. <MAP NAME="skunknav">
  202.   <AREA SHAPE="rect" COORDS="347,1,460,26" HREF="$homeref/$shortname">
  203.   $oplink
  204.   $onlink
  205.   <AREA SHAPE="rect" COORDS="3,1,93,26" HREF="/skunkware/index.html">
  206. </MAP>
  207.  
  208. <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%" BORDER="0">
  209.   <TR ALIGN="LEFT" VALIGN="TOP">
  210.     <TD ROWSPAN="2" WIDTH="20%">
  211. <A HREF="http://www.sco.com/skunkware">
  212.       <IMG BORDER=0 SRC="gif/sk97s.gif" HEIGHT="104" WIDTH="108" ALIGN="BOTTOM">
  213. </A>
  214.     </TD>
  215.     <TD VALIGN="BOTTOM" WIDTH="79%">
  216.       <IMG ISMAP USEMAP="#skunknav" SRC="gif/skunknav.gif" HEIGHT="26"
  217.           WIDTH="466" ALIGN="BOTTOM" BORDER="0">
  218.     </TD>
  219.   </TR>
  220.   <TR>
  221.     <TD VALIGN="TOP">
  222.       <IMG SRC="gif/${shortname}.gif" ALT="$title" HEIGHT="26" ALIGN="BOTTOM">
  223.     </TD>
  224.   </TR>
  225. </TABLE>
  226.  
  227. <H2 ALIGN="CENTER">Last Updated: $now</H2>
  228. EOF
  229.   }
  230. }
  231.  
  232. sub skunkfooter {
  233.     my($foo) = @_;
  234.  
  235.     if ($isweb) {
  236. #
  237. # Print out the footer of a page for the On-line version of the page.
  238. # This should conform to the corporate guidelines.
  239. #
  240.         print OUTPUT <<EOF;
  241. <P><HR ALIGN=LEFT>
  242. <P> <FONT SIZE=-2>
  243. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  244. </FONT>
  245. </BODY>
  246. </HTML>
  247. EOF
  248.     } else {
  249. #
  250. # Print out the fotter for the CD-ROM version.
  251. #
  252.         print OUTPUT <<EOF;
  253. <P><HR ALIGN=LEFT>
  254. <P> <FONT SIZE=-2>
  255. © Copyright 1997 The Santa Cruz Operation, Inc. All rights reserved.
  256. </FONT>
  257. </BODY>
  258. </HTML>
  259. EOF
  260.     }
  261. }
  262.  
  263. sub start_packagelist {
  264.     my($foo) = @_;
  265.  
  266.     print OUTPUT <<EOF;
  267. <H2 ALIGN="CENTER">Package List</H2>
  268. <CENTER><TABLE WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="2">
  269.   <TR>
  270.     <TH WIDTH="11%" HEIGHT="23">Name</TH>
  271.     <TH WIDTH="62%">Description</TH>
  272.     <TH WIDTH="9%">Version</TH>
  273.     <TH WIDTH="7%">OSR5</TH>
  274.     <TH WIDTH="11%">UnixWare</TH>
  275.   </TR>
  276. EOF
  277. }
  278.  
  279. sub end_packagelist {
  280.     my($foo) = @_;
  281.  
  282.     print OUTPUT <<EOF;
  283. </TABLE></CENTER>
  284. <H4><HR ALIGN="LEFT"></H4>
  285. EOF
  286. }
  287.  
  288. sub startpack {
  289.     my($linkref,$desc) = @_;
  290.     print OUTPUT <<EOF;
  291. <H4><A NAME="$linkref"></A>$desc</H4>
  292. <BLOCKQUOTE>
  293. EOF
  294. }
  295.  
  296. sub endpack {
  297.     my($foo) = @_;
  298.  
  299.     print OUTPUT <<EOF;
  300. </BLOCKQUOTE>
  301. <P> </P>
  302. EOF
  303. }
  304.  
  305. sub source {
  306.     my($site) = @_;
  307.  
  308.     print OUTPUT <<EOF;
  309. <P>
  310. <A HREF="$site">
  311.   <IMG SRC="gif/origsrc.gif" ALT="Original source code" HSPACE="20" BORDER="0"
  312.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  313. <A HREF="$site">$site</A></P>
  314. EOF
  315. }
  316.  
  317. sub homepage {
  318.     my($page) = @_;
  319.  
  320.     print OUTPUT <<EOF;
  321. <P>
  322. <A HREF="$page">
  323.   <IMG SRC="gif/homepage.gif" ALT="Package Home page" HSPACE="20" BORDER="0"
  324.             HEIGHT="32" WIDTH="160" ALIGN="CENTER"></A>
  325. <A HREF="$page">$page</A></P>
  326. EOF
  327. }
  328.  
  329. sub osr5dist {
  330.     my($location) = @_;
  331.     my($volfile);
  332.     if ($location =~ /osr5\//) {
  333.         if (not $location =~ /\/$/) {
  334.             $location = "$location/";
  335.         }
  336.         $volfile="${location}VOLS.tar";
  337.         print OUTPUT <<EOF;
  338. <P><A HREF="$baseref/$volfile">
  339.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  340.   ALIGN="CENTER" ALT="OpenServer Distribution"></A>
  341. <A HREF="$baseref/$location">$location</A></P>
  342. EOF
  343.     } else {
  344.         print OUTPUT <<EOF;
  345. <P><A HREF="$location">
  346.   <IMG SRC="gif/osr5dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  347.   ALIGN="CENTER" ALT="OpenServer Distribution">
  348. $location
  349. </A></P>
  350. EOF
  351.     }
  352. }
  353.  
  354. sub uw2dist {
  355.     my($location) = @_;
  356.     my($volfile);
  357.     if ($location =~ /uw2\//) {
  358.         if (not $location =~ /\/$/) {
  359.             $location = "$location/";
  360.         }
  361.         print OUTPUT <<EOF;
  362. <P><A HREF="$baseref/$location">
  363.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  364.   ALIGN="CENTER" ALT="UnixWare Distribution"></A>
  365. <A HREF="$baseref/$location">$location</A></P>
  366. EOF
  367.     } else {
  368.         print OUTPUT <<EOF;
  369. <P><A HREF="$location">
  370.   <IMG SRC="gif/uw2dist.gif" HSPACE="20" BORDER="0" HEIGHT="32" WIDTH="160"
  371.   ALIGN="CENTER" ALT="UnixWare Distribution">
  372. $location
  373. </A></P>
  374. EOF
  375.     }
  376. }
  377.  
  378. sub packlist{
  379.     my($foo) = @_;
  380.     my($linkref,$desc,$packver,$isosr5,$isuw2) = split(/;/, $foo);
  381.  
  382.     print OUTPUT <<EOF;
  383. <TR>
  384.   <TD><A HREF="#$linkref">$linkref</A></TD>
  385.   <TD>$desc</TD>
  386.   <TD>$packver</TD>
  387.   <TD ALIGN="CENTER">$isosr5</TD>
  388.   <TD ALIGN="CENTER">$isuw2</TD>
  389. </TR>
  390. EOF
  391. }
  392.  
  393. LINE: while (defined($line = <TEMPLATE>)) {
  394.     next LINE if $line =~ /^# [0-9]* \"/;
  395.     chop $line;
  396.     if ($line =~ s/@@\@SKUNKHEADER\((.*)\)//) { skunkheader($1);}
  397.     elsif ($line =~ s/@@\@SKUNKFOOTER//) { skunkfooter();}
  398.     elsif ($line =~ s/@@\@START_PACKAGELIST//) {start_packagelist();}
  399.     elsif ($line =~ s/@@\@END_PACKAGELIST//) {end_packagelist();}
  400.     elsif ($line =~ s/@@\@STARTPACK\((.*);(.*)\)//) {startpack($1,$2);}
  401.     elsif ($line =~ s/@@\@ENDPACK//) {endpack();}
  402.     elsif ($line =~ s/@@\@OSR5DIST\((.*)\)//) {osr5dist($1);}
  403.     elsif ($line =~ s/@@\@UW2DIST\((.*)\)//) {uw2dist($1);}
  404.     elsif ($line =~ s/@@\@SOURCE\((.*)\)//) {source($1);}
  405.     elsif ($line =~ s/@@\@HOMEPAGE\((.*)\)//) {homepage($1);}
  406.     elsif ($line =~ s/@@\@PACKLIST\((.*)\)//) {packlist($1);}
  407.     else {print OUTPUT "$line\n";}
  408. }
  409.